package com.cn.struts;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.cn.struts.LoginCheck;

public class LoginConf extends HttpServlet{
  
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	   throws ServletException, IOException
	   {
		String name=req.getParameter("uname");
		String password=req.getParameter("upassword");
		LoginCheck lc=new LoginCheck();
		 System.out.println(name);
		if(lc.isLogin(name, password)){
			req.setAttribute("login", "true");
			req.getRequestDispatcher("login_success.jsp").forward(req, resp);
			//req.getRequestDispatcher("login_failure.jsp").forward(req, resp);
		}else{
			req.getRequestDispatcher("login_failure.jsp").forward(req, resp);
		}
		
	   }
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
	   throws ServletException, IOException
	   {
		doGet(req,resp);
	   }
}
